package com.achievement.dao;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.achievement.entity.Score;
@Repository
public interface ScoreRepository extends PagingAndSortingRepository<Score, Long>, JpaSpecificationExecutor<Score> {
	@Query(value="select avg(score) from Score s where s.exam.id=?1")
	public float findAverageByExamId(Long id);
	@Query(value="select count(*) from Score s where s.score<60 and s.exam.id=?1")
	public Integer findFailByExamId(Long id);
	@Query(value="select count(*) from Score s where s.score>=60 and s.score<80 and s.exam.id=?1")
	public Integer find60_80NumByExamId(Long id);
	@Query(value="select count(*) from Score s where s.score>=80 and s.exam.id=?1")
	public Integer findL80ByExamId(Long id);
}
